#include <array>
#include <iostream>
#include <string>
#include "DateTimeTest.h"

using namespace SystemTool;

void DateTimeTest()
{
    DateTime dt = DateTime::Now();
    std::time_t t = dt.ToMsTime_t();
    std::cout << "Current time(ms)=" << t << std::endl;
    DateTime dt1 = DateTime::FromMsTime_t(t);
    if(dt == dt1)
    {
        std::cout << "dt==dt1" << std::endl;
    }
    else 
    {
        std::cout << "dt!=dt1" << std::endl;
    }
    std::string strTime = dt1.ToString();
    std::cout << "dt1=" << strTime << std::endl;
    DateTime dt2 = DateTime::FromString(strTime);
    if(dt1 == dt2)
    {
        std::cout << "dt1==dt2" << std::endl;
    }
    else 
    {
        std::cout << "dt1!=dt2" << std::endl;
    }

    t = dt.ToSTime_t();
    std::cout << "Current time(s)=" << t << std::endl;
    DateTime dt11 = DateTime::FromSTime_t(t);
    if(dt == dt11)
    {
        std::cout << "dt==dt11" << std::endl;
    }
    else 
    {
        std::cout << "dt!=dt11" << std::endl;
    }

    int iYear = dt11.GetYear();
    std::cout << "Year=" << iYear << std::endl;
    int iMonth = dt11.GetMonth();
    std::cout << "Month=" << iMonth << std::endl;
    int iDay = dt11.GetDay();
    std::cout << "Day=" << iDay << std::endl;
    int iHour = dt11.GetHour();
    std::cout << "Hpur=" << iHour << std::endl;
    int iMinute = dt11.GetMinute();
    std::cout << "Minute=" << iMinute << std::endl;
    int iSec = dt11.GetSecond();
    std::cout << "Second=" << iSec << std::endl;
    int iMilliSec = dt11.GetMilliSecond();
    std::cout << "MilliSec=" << iMilliSec << std::endl;
    int iMicroSec = dt11.GetMicroSecond();
    std::cout << "MicroSec=" << iMicroSec << std::endl;
}
